
function display(){
	$(".vehicleClass ul li").css("display", "block");
}

function homeImage(){
	$("iframe").attr("src", "homeImage.jsp");
}

var parentId = "";
$(function(){
	var args = window.location.href.split('?')[1];
	var pageName = args.split('&')[1].split('=')[1];
	parentId = args.split('&')[0].split('=')[1];
	$("#txtparentId").val(decodeURIComponent(pageName) + "-"+parentId +"");
});

function addLimit(){
	var parentId = $("#txtparentId").val().split('-')[1];
	var pageName = $("#txtpageName").val();
	if(pageName == ""){
		layer.alert("节点名称不能为空！", 2);
		return;
	}
	
	var pageUrl = $("#txtpageUrl").val();
	if(pageUrl == ""){
		layer.alert("节点路径不能为空！", 2);
		return;
	}
	
	var addMan = "管理员";
	var limitLevel = "";
	for(var i =0; i< 7; i++){
		if($("#chkLimit"+i).attr("checked") == "checked"){
			limitLevel += i.toString();
		}
	}
	
	if(limitLevel == ""){
		layer.alert("请选择节点权限！", 2);
		return;
	}
	
	var nodeType = "";
	for(var i =0; i< 6; i++){
		if($("#radioType"+i).attr("checked") == "checked"){
			nodeType += i.toString();
		}
	}
	
	if(nodeType == ""){
		layer.alert("请选择节点类型！", 2);
		return;
	}
	var limit = new Object();
	limit.parentId =parentId;
	limit.pageName = pageName;
	limit.pageUrl = pageUrl;
	limit.remark = " ";
	limit.addMan = addMan;
	limit.limitLevel = limitLevel;
	limit.nodeType = nodeType;
	var json = JSON.stringify(limit);
	$.ajax({
		type : 'post',
		dataType : 'text',
		contentType : "application/json",
		data : json,
		async : false,
		url :  ctx + "/admin/super/pl.do?action=0",
		success : function(result) {
			if(result=="1"){				
				layer.alert("添加成功!",1);
				setTimeout(function(){window.location.href="limit.jsp";},2000);
				
			}else if(result=="0"){
				layer.alert("添加失败!",2);
			}else if(result=="2"){
				layer.alert("已有相同的节点!",2);
			}else if(result=="3"){
				layer.alert("已有一个根节点，请重新进入该页面!",2);
			}
		}
	});
	
}

function returnLimit(){
	window.location.href="limit.jsp";
}